package myGUI;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;

public class MainGui {

	private JFrame frmVpn;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainGui window = new MainGui();
					window.frmVpn.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public MainGui() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmVpn = new JFrame();
		frmVpn.setTitle("eece412 VPN");
		frmVpn.setBounds(100, 100, 300, 120);
		frmVpn.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JMenuBar menuBar = new JMenuBar();
		frmVpn.setJMenuBar(menuBar);
		
		JMenu mnMode = new JMenu("Mode");
		menuBar.add(mnMode);
		
		JMenuItem mntmClientMode = new JMenuItem("Client Mode");
		mntmClientMode.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ClientGUI client = new ClientGUI();
				client.setVisible(true);
//				frmVpn.getContentPane().removeAll();
//				TCPClientGui clientPanel = new TCPClientGui();
//				frmVpn.getContentPane().add(clientPanel, BorderLayout.CENTER);
//				frmVpn.validate();
			}
		});
		mnMode.add(mntmClientMode);
		
		JMenuItem mntmServerMode = new JMenuItem("Server Mode");
		mntmServerMode.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ServerGUI server = new ServerGUI();
				server.setVisible(true);
//				frmVpn.getContentPane().removeAll();
//				TCPServerGui serverPanel = new TCPServerGui();
//				frmVpn.getContentPane().add(serverPanel, BorderLayout.CENTER);
//				frmVpn.validate();
			}
		});
		mnMode.add(mntmServerMode);
		frmVpn.getContentPane().setLayout(null);
		
		JButton btnClientMode = new JButton("Client Mode");
		btnClientMode.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ClientGUI client = new ClientGUI();
				client.setVisible(true);
			}
		});
		btnClientMode.setBounds(10, 11, 126, 23);
		frmVpn.getContentPane().add(btnClientMode);
		
		JButton btnServerMode = new JButton("Server Mode");
		btnServerMode.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ServerGUI server = new ServerGUI();
				server.setVisible(true);
			}
		});
		btnServerMode.setBounds(148, 11, 126, 23);
		frmVpn.getContentPane().add(btnServerMode);
		
	}

}
